import { insCategoryList, reqBannerList, reqFloorList } from "@/api"
//home模块得小仓库
const state = {
    //根据接口的返回值进行初始化
    categoryList: [],
    bannerList: [],
    floorList: []
}
const mutations = {
    //形参：state获取的数据  categoryList使用的数据
    CATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList
    },
    BANNERLIST(state, bannerList) {
        state.bannerList = bannerList
    },
    FLOORLIST(state, floorList) {
        state.floorList = floorList
    }
}
const actions = {
    //通过API里面的接口函数调用，向服务器发请求，获取服务器的数据
    async categoryList({ commit }) {
        let result = await insCategoryList()
        if (result.code == 200) {
            commit("CATEGORYLIST", result.data)
        }
    },
    async getBannerList({ commit }) {
        let result = await reqBannerList()
        if (result.code == 200) {
            commit('BANNERLIST', result.data)
        }
    },
    async getFloorList({ commit }) {
        let result = await reqFloorList()
        if (result.code == 200) {
            commit("FLOORLIST", result.data)
        }
    }
}
const getters = {}
export default ({
    state,
    actions,
    mutations,
    getters
})